import React from 'react'
import {get, put_http} from '../../../axios'
import moment from 'moment'
class MyNotificationDetail extends React.Component {
    constructor(props) {
        super(props)
        this.state = {
            msg: {sys_message:{}}
        }
    }
    componentDidMount() {
        let id = this.props.match.params.id
        // this.read_msg(id)
        this.get_msg(id)
    }

    get_msg(id) {
        get(`/mem/messages/${id}`).then(resp => {
            if (resp&&resp.success) {
                this.setState({msg: resp.data})
            }
        })
    }
    // read_msg(id) {
    //     put_http(`/mem/messages/${id}`, {read: 0}).then(resp => {
    //         if (resp) {
    //             console.log(resp)
    //         }
    //     })
    // }
    render() {
        const {msg} = this.state
        return(
            <div class="tidings-details">
                <h3>{msg.sys_message.title}</h3>
                <p>{msg.sys_message.content}</p>
                <div class="time">{moment(msg.sys_message.created_at).format('l')}</div>
            </div>
        )
    }
}

export default MyNotificationDetail